<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
     <#assign base=request.contextPath  />
     <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css">
    <link rel="stylesheet" href="${base}/frame/static/css/style.css">
    <link rel="icon" href="${base}/frame/static/image/code.png">
    <style type="text/css">
    </style>
    <style>
        .layui-table-cell{
            height: auto;
            line-height: ;
        }
    </style>
</head>
<body class="body">
        <!-- 工具集 -->
        <div class="my-btn-box">
            <span style="height: 50px;">
                <div class="layui-input-inline">
                	<label class="layui-form-label">车辆品牌</label>
                    <input type="text" autocomplete="off" placeholder="品牌"id="carBrand" class="layui-input" style="width: 150px;height: 31px;margin-top: 4px;">
                </div>
                <button class="layui-btn  layui-btn-sm layui-btn-normal" id="seche22">查询</button>
            </span>
        </div>
        <!-- table -->
       <table class="layui-hide" id="test" lay-filter="test"></table>
			<script type="text/html" id="barDemo">
                {{#  if(d.sentsuitation ==1){ }}
                <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail"  href="javascript:void(0)"  onclick="Reservable('{{d.id}}')">未租出</a>
                {{#  } else { }}
                <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail" href="javascript:void(0)"  onclick="Reservable2('{{d.id}}')">已租出 </a>

                {{#  } }}
			</script>

        <script src="${base}/js/jquery.min.js"></script>
        <script   src="${base}/frame/layui/layui.all.js"></script>
        <script type="text/javascript" src="${base}/js/index.js"></script>
<script type="text/javascript">

    // layui方法
    layui.use(['tree', 'table', 'vip_table', 'layer'], function () {

        // 操作对象
        var table = layui.table
                , vipTable = layui.vip_table
                , layer = layui.layer
                , $ = layui.jquery;

        // 表格渲染
        var tableIns = table.render({
		    even: true,//开启隔行背景
			url: '${base}/car/carclist?ptname=${ptname}',
			title: '用户数据表',
            toolbar: '#toolbarDemo',
            size: 'sm',//小尺寸的表格
            elem: '#test',                  //指定原始表格元素选择器（推荐id选择器）
            cols: [[                  //标题栏
                {
                    field: 'url', title: '车辆照片', width:90,
                    templet: function (val) {
                        var url = val.url;
                        return '<div><img src="${base}/car/getPhoto?path=' + url + '"></div>'
                    }
                }
                ,{field: 'ptName', title: '所属公司',width:90}
                ,{field: 'carName', title: '车辆名',width:80}
                , {field: 'carBrand', title: '车辆品牌',width:90}
                , {field: 'carType', title: '车辆型号',width:90}
                , {field: 'carMoeny', title: '车辆价格',width:90}
                , {field: 'carKm', title: '里程数',width:80}
                , {field: 'carSize', title: '容积',align: 'center'}
                , {field: 'load', title: '载重',align: 'center'}
                , {field: 'renewal', title: '续航',align: 'center'}
                , {field: 'wheelbase', title: '轴距',align: 'center'}
                , {field: 'insurance', title: '有无保险',width:90}
                ,{field:'sentsuitation',templet:function(val){
                        if(val.sentsuitation=="1"){
                            return "已租出";
                        }else{
                            return "未租出";
                        }
                    }, title: '状态', align:'center'}
                , {field: 'xxxxx', title: '操作',align: 'center', toolbar: '#barDemo'}
            ]]
            , id: 'dataCheck'
            , method: 'get'
            ,height:480
            ,page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip']
                ,theme: '#9AC747'
                ,limit: 10
            }
        });
		  //监听行工具事件
		  table.on('tool(test)', function(obj){
		    var data = obj.data;
		    //console.log(obj)
		    if(obj.event === 'edit'){
				layer.open({
			        type: 1
			        ,offset: type
			        ,id: 'layerDemo'+type //防止重复弹出
			        ,content: '<div style="padding: 20px 100px;">'+ text +'</div>'
			        ,btn: '关闭'
			        ,btnAlign: 'r' 
			        ,shade: 0 
			        ,yes: function(){
			          layer.closeAll();
			        }
			      });
		    }
		  });

    });
    //键盘事件
    $("body").bind("keydown",function(e){
        // 兼容FF和IE和Opera
        var theEvent = e || window.event;
        var code=theEvent.keyCode || theEvent.which || theEvent.charCode;
        if (code==13) {
            //回车执行查询
            $("#seche22").click();
        }
    });
    $('#seche22').on('click',function () {
        var carBrand=$("#carBrand").val();

        //表刷新方法
        var table = layui.table;
        table.reload(
                'dataCheck',{url:'${base}/car/searchcardetail?ptname=${ptname}',
                    where:{carBrand:carBrand} //设定异步数据接口的额外参数
                });

    })
    function Reservable(id){

        $.ajax({
            type:"POST",
            url:"${base}/car/update",
            data:{"id":id},
            async:false,
            success:function(data){

                var table = layui.table;
                //表刷新方法
                table.reload('dataCheck', {
                    url: '${base}/car/carclist?ptname=${ptname}'
                    ,where: {}, //设定异步数据接口的额外参数
                    //height: 300
                });

            }
        });
    }

    function Reservable2(id){

        $.ajax({
            type:"POST",
            url:"${base}/car/update2",
            data:{"id":id},
            async:false,
            success:function(data){

                var table = layui.table;
                //表刷新方法
                table.reload('dataCheck', {
                    url: '${base}/car/carclist?ptname=${ptname}'
                    ,where: {}, //设定异步数据接口的额外参数
                    //height: 300
                });

            }
        });
    }



</script>
</body>
</html>